﻿using System.Web;
using Wedn.Net.UI.Handlers;

namespace Wedn.Net.Web.Handlers
{
    /// <summary>
    /// 加载外链JavaScript执行脚本文件
    /// </summary>
    public class LoadScripts : LoadHandler
    {
        /// <summary>
        /// PR方法
        /// </summary>
        /// <param name="context"></param>
        public override void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/x-javascript";
            #region MyRegion
            //string load = context.Request.QueryString["load"];
            //if (load == null)
            //    context.Response.End();
            //string dir = context.Request.QueryString["dir"] ?? "scripts";
            //string[] scripts = load.Split(',');
            //string pathFormat = "/Content/" + dir.Replace('.', '/') + "/{0}.js"; 
            //StringBuilder sbd = new StringBuilder();
            //foreach (string item in scripts)
            //{
            //    string path = context.Server.MapPath(string.Format(pathFormat, item.Replace('.', '/')));
            //    if (File.Exists(path))
            //        sbd.AppendLine(File.ReadAllText(path, Encoding.UTF8));
            //}
            //if (sbd.Length == 0)
            //{
            //    context.Response.Clear();
            //    context.Response.End();
            //}
            //context.Response.Write(sbd.ToString()); 
            #endregion
            Load(context);
        }
    }
}